﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using blackhouse.BlackApart.Business.Reservations;

namespace blackhouse.BlackApart.Business.ApartmentServices {
    public sealed class ReservationServices {

        #region Fields

        #endregion

        #region Properties

        public IAdditionalService[] Services { get; private set; }
        public ReservationAdditionalService[] ServicesOnReservation { get; private set; }
        public double TotalCost { get; private set; }

        #endregion

        #region Constructors

        public ReservationServices(IWebReservation reservation) {
            this.Services = Factory.Instance().GetAdditionalService().GetServicesForReservation(reservation.ReservationId);
            List<ReservationAdditionalService> reservationServices = new List<ReservationAdditionalService>();
            foreach (IAdditionalService service in this.Services) 
                reservationServices.Add(service.GetOrderFromReservation(reservation));
            this.ServicesOnReservation = reservationServices.ToArray();
            this.TotalCost = this.ServicesOnReservation.Sum(ras => ras.Price);
        }

        #endregion

    }
}
